package com.css.fxfzxczh.modules.aftershockSequence.service.impl;

import com.css.fxfzxczh.modules.aftershockSequence.entity.AftershockSequence;
import com.css.fxfzxczh.modules.aftershockSequence.repository.AftershockSequenceRepository;
import com.css.fxfzxczh.modules.aftershockSequence.service.AftershockSequenceService;
import com.css.fxfzxczh.modules.aftershockSequence.vo.AftershockSequenceVO;
import com.css.fxfzxczh.modules.synthesizeInfoManage.earEveManage.entity.EarEveManage;
import com.css.fxfzxczh.modules.synthesizeInfoManage.earEveManage.service.EarEveManageService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Author:
 * @CreateTime: 2024/4/7 9:33
 * @Description:
 */
@Service
@Slf4j
public class AftershockSequenceServiceImpl implements AftershockSequenceService {

    @Resource
    private AftershockSequenceRepository aftershockSequenceRepository;

    @Resource
    private EarEveManageService earEveManageService;


    @Override
    public List<AftershockSequence> getAftershockSequenceData(AftershockSequenceVO aftershockSequenceVO) {
        List<AftershockSequence> list = new ArrayList<>();
        aftershockSequenceVO.setEndTime(new Date().toString());
        List<AftershockSequence> aftershockSequenceList = aftershockSequenceRepository.getAftershockSequenceData(aftershockSequenceVO);
        //获取当前地震事件
        EarEveManage currentEvent = earEveManageService.getCurrentEvent();
        aftershockSequenceList.forEach(item->{
            //筛选出在当前地震事件下6度圈内的地震
            Boolean boo = aftershockSequenceRepository.whetherInTheSixIntensityCircle(currentEvent.getXsemId(),item.getId());
            if(boo){
                list.add(item);
            }
        });


        return list;
    }
}
